package com.example.sbbsec.quartz.schedule.impl;


import com.example.sbbsec.quartz.entity.schedule.simple.SimpleJob;
import com.example.sbbsec.quartz.schedule.BaseJobService;
import com.example.sbbsec.quartz.util.QuartzUtil;
import org.quartz.Trigger;
import org.springframework.stereotype.Service;

/**
 * 定时任务接口服务 实现类
 *
 * @author lowe.yang
 * @date 2019-01-25 16:43
 */
@Service("simpleJobService")
public class SimpleJobServiceImpl extends BaseJobService<SimpleJob> {

    @Override
    protected Trigger buildTrigger(SimpleJob job) {
        return QuartzUtil.buildSimpleTrigger(job);
    }

    @Override
    protected void checkJob(SimpleJob job) {
        super.checkJob(job);

        if (job.getInterval() == null) {
            throw new IllegalArgumentException("interval can not be null");
        }
        if (job.getUnit() == null) {
            throw new IllegalArgumentException("unit can not be null");
        }
        if (job.getRepeat() == null) {
            throw new IllegalArgumentException("repeat can not be null");
        }
    }
}

